package Game.Items.Weapons;

import java.util.Random;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Vector2f;

import Game.GameHelper;
import Game.Items.GameItem;
import Game.Objects.*;
import Game.Objects.Creatures.GOCreature;
import Tools.Drawing.FontTagSystem;

/** Club With Spikes class
 * @author Aikidos
 */
public class GIClubWithSpikes extends GameItem {

	// Stats
	private int _minDamage = 4;
	private int _maxDamage = 5;
	
	public GIClubWithSpikes() {
		super("Club With Spikes");
		
		IsEquip = true;
		Category = ECategory.Weapon;
		
		_weight = 2.4f;
		
		// Set damage
		Random rnd = GameHelper.getRandom();
		_minDamage = rnd.nextInt(_minDamage) + 1;
		_maxDamage = rnd.nextInt(_maxDamage) + _minDamage;
		if (_minDamage == _maxDamage) _maxDamage++;
	}
	
	@Override
	public void on() { 
		if (!_isOn)
		{
			_isOn = true;
			
			if (_ownerGameObject.isCreature())
			{
				GOCreature creature = (GOCreature)_ownerGameObject;
				creature.MinDamage += _minDamage;
				creature.MaxDamage += _maxDamage;
			}
			
			if (_ownerGameObject.isPlayer())
			{
				GOPlayer player = (GOPlayer)_ownerGameObject;
				player.MinDamage += _minDamage;
				player.MaxDamage += _maxDamage;
			}
		}
	}
	
	@Override
	public void off() {
		if (_isOn)
		{
			_isOn = false;
			
			if (_ownerGameObject.isCreature())
			{
				GOCreature creature = (GOCreature)_ownerGameObject;
				creature.MinDamage -= _minDamage;
				creature.MaxDamage -= _maxDamage;
			}
			
			if (_ownerGameObject.isPlayer())
			{
				GOPlayer player = (GOPlayer)_ownerGameObject;
				player.MinDamage -= _minDamage;
				player.MaxDamage -= _maxDamage;
			}
		}
	}
	
	@Override
	public void drawInfo(Vector2f drawPos, Graphics g) {
		FontTagSystem.drawText("Description:", drawPos);
		
		drawPos.y += 20;
		
		FontTagSystem.drawText("Damage: [red]" 
				+ String.valueOf(_minDamage) + " - " 
				+ String.valueOf(_maxDamage) + "[/red]", drawPos);
	}
	
}
